** Variable Explanations 
** Dependent Variables
** Popvote_update	1 = respondent cast a ballot for a populist party in the last national election; 0 = all other votes.
** Popvote_update_nongov	Same as above, but coded 1 only for non-governing populist parties.
** Popvote_update_FRIT	Same as Popvote_update, but set to missing for France and Italy (used in the FR/IT exclusion check).
** RIGHTPOPvote	1=Vote for any populist right parties (governing + opposition).
** Leftvote_exPOP	Vote for a mainstream or radical left party excluding left-wing populists.
** POPident_update	1= Individual self-identification with populist parties, 0= otherwise
** Independent Variables
** import_shock_new:	Chinese import-competition shock at the NUTS-1/NUTS-2 regional level (Δ Chinese imports in industry × pre-shock employment share). Continuous.
** import_shock_new_3year_update / _5year / _10year	Moving-average versions of the shock (3-, 5-, 10-year windows).
** import_shock	Legacy version of the same shock (kept for robustness checks).
** import_shock_usa	Instrument: US-wide China-shock series interacted with local industry mix; used in IV (Autor–Dorn–Hanson style).
** congruence_cdf_pop100	Ideological congruence
** congruence_cdf_update / _agg / _dif	Alternative ways of measuring congruence (e.g., updated party positions, country-level aggregation, first-differences).
** l_congruence_cdf_pop100	One-period lag of congruence_cdf_pop100 (used to reduce simultaneity).
** ideo_blur / ideo_econ_blur	Party-system "ideological blurriness" on overall left–right or economic left–right scale.
** group_size	Cell size for multilevel bootstrap; used to omit tiny region–year clusters (< 100 obs).
** int1 / int2	On-the-fly interactions created in the IV section:
** int1 = import_shock_new × congruence_cdf_pop100
** int2 = import_shock_usa × congruence_cdf_pop100
** Age: age
** Gender: female=1, male=0
** Education: Years of education
** Interest: Political Interest
** ln_district	Natural log of district magnitude 
** gdp_growth: gdp growth
** inflation_gdp: inflation as a percentage of gdp
** net_migration_flowofpop: net migration rate (adjusted for population)


local control ln_gdp_per_capita gdp_growth inflation_gdp net_migration_flowofpop
local ind_con Age Gender Education Interest 

 Trust Unemployed
 
 
*** Table 1

meprobit Popvote_update c.import_shock_new c.congruence_cdf_pop100    i.year if sample==1 || countrycode:   || countrycode_year: ,
 outreg2 using table_1_24a.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

 meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100 i.year  if sample==1    || countrycode:  || countrycode_year: ,
 outreg2 using table_1_24a.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append


*** with control
meprobit Popvote_update c.import_shock_new c.congruence_cdf_pop100  `control' `ind_con'   i.year  || countrycode:   || countrycode_year: ,
 outreg2 using table_1_24b.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

 meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100   `control' `ind_con'  i.year  || countrycode:  || countrycode_year: ,
 outreg2 using table_1_24b.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append
 
 
 
*** check with PopIden (Table2)
meprobit POPident_update c.import_shock_new c.congruence_cdf_pop100  `control' `ind_con'  i.year || countrycode: || countrycode_year:,
  outreg2 using table_2a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

meprobit POPident_update c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'  i.year || countrycode: || countrycode_year:,
  outreg2 using table_2a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append

*** working (2-level)
meprobit Popvote_update c.import_shock_new c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode_year:,
  outreg2 using table_2b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode_year:,
 outreg2 using table_2b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append
 

 
** Figure2

meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'    i.year  || countrycode: || countrycode_year:,

margins, dydx(import_shock) at(congruence_cdf_update=(0(0.5)2))
marginsplot, ///
             graphregion(color(white))     /// get rid of the gray outerbox
             ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot)) /// add dash
             recast(line)    /// get rid of the big dots
             yline(0, lpattern(solid)           /// add dash horizontal line at 0
             lwidth(vthin) lcolor(black))    /// make line thin, black
             ylabel( , angle(0) nogrid)       /// horiz. y-axis labels & no grid
             xtitle("")         /// x-axis title
             xlabel(0 "0" 0.5 "0.5" 1 "1" 1.5 "1.5" 2 "2", labsize(2.5) nogrid) ///
             xtitle("Ideological Incongruence") ///
             ytitle("Marginal Effect of China Import Shock") /// y-axit title
             title("Marginal Effect Based on Coefficient Estimates in Model 4") /// main title
             note("95% confidence intervals")     /// small note of confidence int.
             addplot(hist congruence_cdf_update if congruence_cdf_update<=2, color(gs14%40)      /// add the density
             yaxis(2) yscale(off axis(2)))

			 

   *** using ivreg2
generate int1=import_shock_new*congruence_cdf_pop100
generate int2=import_shock_usa*congruence_cdf_pop100
  


  ** Table 3 Iv regression ivprobit
ivprobit Popvote_update congruence_cdf_pop100  `control' `ind_con'   i.countrycode i.year (import_shock_new =import_shock_usa )[pweight=pspwght],  vce(cluster region_year)  
  outreg2 using table_3a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

ivprobit Popvote_update congruence_cdf_pop100  `control' `ind_con'   i.countrycode i.year (import_shock_new int1=import_shock_usa int2)[pweight=pspwght],  vce(cluster region_year)  
  outreg2 using table_3a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append
  
 ivreg2 Popvote_update congruence_cdf_pop100 `control' `ind_con'    i.countrycode i.year (import_shock_new =import_shock_usa)[pweight=pspwght],  robust
  outreg2 using table_3b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

  ivreg2 Popvote_update congruence_cdf_pop100 `control' `ind_con'    i.countrycode i.year (import_shock_new int1=import_shock_usa int2)[pweight=pspwght], robust
  outreg2 using table_3b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append



 
*** Table 4 left support
meprobit Leftvote_exPOP c.import_shock_new c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_4_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

meprobit Leftvote_exPOP c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_4_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append

  
*** Figure 3

margins, dydx(import_shock_new) at(congruence_cdf_pop100=(0(0.5)2))
marginsplot, ///
             graphregion(color(white))     /// get rid of the gray outerbox
             ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot)) /// add dash
             recast(line)    /// get rid of the big dots
             yline(0, lpattern(solid)           /// add dash horizontal line at 0
             lwidth(vthin) lcolor(black))    /// make line thin, black
             ylabel( , angle(0) nogrid)       /// horiz. y-axis labels & no grid
             xtitle("")         /// x-axis title
             xlabel(0 "0" 0.5 "0.5" 1 "1" 1.5 "1.5" 2 "2", labsize(2.5) nogrid) ///
             xtitle("Ideological Incongruence") ///
             ytitle("Marginal Effect of China Import Shock") /// y-axit title
             title("Marginal Effect Based on Coefficient Estimates in Model X") /// main title
             note("95% confidence intervals")     /// small note of confidence int.
             addplot(hist congruence_cdf_pop100 if congruence_cdf_pop100<=2, color(gs14%40)      /// add the density
             yaxis(2) yscale(off axis(2)))
  

 *** Use different time period (Table A1)
** 3, and 10 years import_shock_new_3year_update import_shock_new_5year import_shock_new_10year
meprobit Popvote_update c.import_shock_new_3year_update c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_A1a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

meprobit Popvote_update c.import_shock_new_3year_update##c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_A1a_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append

  meprobit Popvote_update c.import_shock_new_10year c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_A1b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace
meprobit Popvote_update c.import_shock_new_10year##c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode: || countrycode_year:,
  outreg2 using table_A1b_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append

  

   ** Robustness check (right popvote): Table A2
 meprobit RightPOPvote c.import_shock_new c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode:  || countrycode_year:,   
   outreg2 using table_a2_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace

 meprobit RightPOPvote c.import_shock_new##c.congruence_cdf_pop100   `control' `ind_con'   i.year  || countrycode: || countrycode_year:,    
     outreg2 using table_a2_24.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append


  ***  Table A3: delete the small region size: less than 100):
 meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100 ln_gdp_per_capita gdp_growth inflation_gdp net_migration_flowofpop  Age Gender Education Interest i.year if group_size>100 || countrycode:  || countrycode_year:,
 
** Table A4: Adding district magnitude
 
 meprobit Popvote_update c.import_shock_new##c.ln_district c.congruence_cdf_pop100  `control' ideo_blur `ind_con'  i.year || countrycode:  || countrycode_year:,
   outreg2 using table_1_19.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replacd
 
  
 meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100##c.ln_district `control' ideo_blur `ind_con'  i.year || countrycode:  || countrycode_year:,
  outreg2 using table_1_19.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append


     
 **  Table A5: Adding ideological blurriness
    meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100  `control' ideo_blur `ind_con'  i.year || countrycode:  || countrycode_year:,
   outreg2 using table_12.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  replace
 
  meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100  `control' ideo_econ_blur `ind_con'  i.year || countrycode:  || countrycode_year:,
   outreg2 using table_12.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append
   
     meprobit Popvote_update c.import_shock_new##c.ideo_blur c.congruence_cdf_pop100  `control'  `ind_con'  i.year || countrycode:  || countrycode_year:,
   outreg2 using table_12.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append
   
     meprobit Popvote_update c.import_shock_new##c.ideo_econ_blur c.congruence_cdf_pop100  `control'  `ind_con'  i.year || countrycode:  || countrycode_year:,
   outreg2 using table_12.doc, bdec(3) se nolabel alpha(0.01, 0.05, 0.1) excel word nor2  append


  **  Table A6: Using country level measure
  meprobit Popvote_update c.import_shock_new##c.congruence_cdf_country1  `control' ideo_econ_blur `ind_con'  i.year || countrycode:  || countrycode_year:,

  
  *** Summary Statistics
su Popvote_update POPident_update 
su import_shock_new import_shock_new_3year_update import_shock_new_10year import_shock_usa  if Popvote_update~=.
su c.congruence_cdf_pop100 `ind_con'  `control' if Popvote_update~=.
 
 *** Figure A3 (Model 6: Identification and Model 8)
 ** Model 6
 meprobit POPident_update c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'  i.year || countrycode: || countrycode_year:,
margins, dydx(import_shock_new) at(congruence_cdf_pop100=(0(0.5)2))
marginsplot, ///
             graphregion(color(white))     /// get rid of the gray outerbox
             ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot)) /// add dash
             recast(line)    /// get rid of the big dots
             yline(0, lpattern(solid)           /// add dash horizontal line at 0
             lwidth(vthin) lcolor(black))    /// make line thin, black
             ylabel( , angle(0) nogrid)       /// horiz. y-axis labels & no grid
             xtitle("")         /// x-axis title
             xlabel(0 "0" 0.5 "0.5" 1 "1" 1.5 "1.5" 2 "2", labsize(2.5) nogrid) ///
             xtitle("Ideological Incongruence") ///
             ytitle("Marginal Effect of China Import Shock") /// y-axit title
             title("Marginal Effect Based on Coefficient Estimates in Model 6") /// main title
             note("95% confidence intervals")     /// small note of confidence int.
             addplot(hist congruence_cdf_pop100 if congruence_cdf_pop100<=2, color(gs14%40)      /// add the density
             yaxis(2) yscale(off axis(2)))
			 
			 
 ** Model 8
meprobit Popvote_update c.import_shock_new##c.congruence_cdf_pop100  `control' `ind_con'  i.year  || countrycode_year:,
margins, dydx(import_shock_new) at(congruence_cdf_pop100=(0(0.5)2))
marginsplot, ///
             graphregion(color(white))     /// get rid of the gray outerbox
             ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot)) /// add dash
             recast(line)    /// get rid of the big dots
             yline(0, lpattern(solid)           /// add dash horizontal line at 0
             lwidth(vthin) lcolor(black))    /// make line thin, black
             ylabel( , angle(0) nogrid)       /// horiz. y-axis labels & no grid
             xtitle("")         /// x-axis title
             xlabel(0 "0" 0.5 "0.5" 1 "1" 1.5 "1.5" 2 "2", labsize(2.5) nogrid) ///
             xtitle("Ideological Incongruence") ///
             ytitle("Marginal Effect of China Import Shock") /// y-axit title
             title("Marginal Effect Based on Coefficient Estimates in Model 8") /// main title
             note("95% confidence intervals")     /// small note of confidence int.
             addplot(hist congruence_cdf_pop100 if congruence_cdf_pop100<=2, color(gs14%40)      /// add the density
             yaxis(2) yscale(off axis(2)))
			 
			 		 
graph combine Figure2a_update.gph Figure2b.gph, xsize(9) ysize(5) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white))

** Figure A4
ivprobit Popvote_update congruence_cdf_pop100  `control' `ind_con'   i.countrycode i.year (import_shock_new int1=import_shock_usa int2)[pweight=pspwght],  vce(cluster region_year)  
#delimit ;
preserve;

set seed 5001;

drawnorm SN_b1-SN_b131, n(100000) means(e(b)) cov(e(V)) clear;


postutil clear;
postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi 
            using sim , replace;
            noisily display "start";
            

local a=1 ;
while `a' <= 10{ ;

    {;

scalar h_import_shock= 0.013;
scalar h_congruence_cdf_update= 1.05;
scalar h_ln_gdp_per_capita =   10.29;
scalar h_gdp_growth=1.83;
scalar h_inflation_gdp = 2.06;
scalar h_net_migration_flowofpop = 0.01;
scalar h_Age =  48.30;   
scalar h_Gender =0;  
scalar h_Education =   12.29;   
scalar h_Interest = 2.36; 
scalar h_Trust =  4.96;
scalar h_unemployed= 0;
scalar h_countrycode2=0;
scalar h_countrycode7=0;
scalar h_countrycode11=0;
scalar h_countrycode12 =0;
scalar h_countrycode13=0;
scalar h_countrycode14=0;
scalar h_countrycode17=0;
scalar h_countrycode20=0;
scalar h_countrycode23=0;
scalar h_countrycode28=0;
scalar h_year2003=0;
scalar h_year2004=0;
scalar h_year2005=0;
scalar h_year2006=0;
scalar h_year2007=0;
scalar h_year2008=0;
scalar h_year2009=0;
scalar h_year2010=0;
scalar h_year2011=0;
scalar h_year2012=0;
scalar h_year2013=0;
scalar h_year2014=0;
scalar h_year2015=0;
scalar h_year2016=0;




    generate x_betahat0  = SN_b1*h_import_shock+ SN_b2*`a'/4 *h_import_shock + SN_b3*`a'/4
	+ SN_b4*h_ln_gdp_per_capita+ SN_b5*h_gdp_growth+ SN_b6*h_inflation_gdp + SN_b7*h_net_migration_flowofpop
	+ SN_b8*h_Age + SN_b9*h_Gender+ SN_b10*h_Education+ SN_b11*h_Interest+ SN_b12*h_Trust+ SN_b13*h_unemployed
    +SN_b42;
    
    
    generate x_betahat1 = SN_b1*(h_import_shock+0.5)+ SN_b2*`a'/4 *(h_import_shock+0.5) + SN_b3*`a'/4
	+ SN_b4*h_ln_gdp_per_capita+ SN_b5*h_gdp_growth+ SN_b6*h_inflation_gdp + SN_b7*h_net_migration_flowofpop
	+ SN_b8*h_Age + SN_b9*h_Gender+ SN_b10*h_Education+ SN_b11*h_Interest+ SN_b12*h_Trust+ SN_b13*h_unemployed
    +SN_b42;
    
    gen prob0=normal(x_betahat0);
    gen prob1=normal(x_betahat1);
    gen diff=prob1-prob0;
    
    egen probhat0=mean(prob0);
    egen probhat1=mean(prob1);
    egen diffhat=mean(diff);
    
    tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi ;  

    _pctile prob0, p(2.5,97.5) ;
    scalar `lo0' = r(r1);
    scalar `hi0' = r(r2);  
    
    _pctile prob1, p(2.5,97.5);
    scalar `lo1'= r(r1);
    scalar `hi1'= r(r2);  
    
    _pctile diff, p(2.5,97.5);
    scalar `diff_lo'= r(r1);
    scalar `diff_hi'= r(r2);  

   
    scalar `prob_hat0'=probhat0;
    scalar `prob_hat1'=probhat1;
    scalar `diff_hat'=diffhat;
    
    post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') 
                (`diff_hat') (`diff_lo') (`diff_hi') ;
    };      
    drop x_betahat0 x_betahat1 prob0 prob1 diff probhat0 probhat1 diffhat ;
    local a=`a'+ 1 ;
    display "." _c;
    } ;

display "";

postclose mypost;

                                
restore;
merge using "sim.dta";
gen MV = ((_n)/4);
replace MV=. if _n>11;


graph twoway hist congruence_cdf_pop100  if congruence_cdf_pop100 <=2.5, width(0.1) percent color(gs14) yaxis(2)
        ||  line diff_hat MV, clwidth(medium) clpattern(solid) clcolor(black)
        ||  line diff_lo MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line diff_hi MV, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
           xlabel(0 (0.5)2, nogrid labsize(3)) 
		               ylabel(0 (0.1) 0.5, axis(1) nogrid labsize(3))
            yscale(noline alt) yscale(noline alt axis(2)) xscale(noline) legend(off)
            yline(0, lcolor(black))
      
            xtitle(Ideological Incongruence, size(3.5))
            ytitle("Marginal Effect of Import Shock", size(3.5))
            ytitle("Percent of Observations" , axis(2) size(3.5))
            xsca(titlegap(4)) ysca(titlegap(4)) ysca(axis(2) titlegap(4))
            scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));
        
      
          ;
            
log close;

 ivreg2 Popvote_update congruence_cdf_pop100 `control' `ind_con'    i.countrycode i.year (import_shock_new int1=import_shock_usa int2)[pweight=pspwght], robust
  
# delimit ;
set more off;



matrix b=e(b);
matrix V=e(V);

scalar b1=b[1,1];
scalar b2=b[1,2];

scalar varb1=V[1,1];
scalar varb2=V[2,2];

scalar covb1b2=V[1,2];

scalar list b1 b2 varb1 varb2 covb1b2;


generate MVZ=((_n-1)/4);

replace  MVZ=. if _n>=12;

gen conbx=b1+b2*MVZ if _n<=12;

gen consx=sqrt(varb1+varb2*(MVZ^2)+2*covb1b2*MVZ) if _n<=12;

gen ax=1.96*consx;

gen upperx=conbx+ax;

gen lowerx=conbx-ax;

*     ****************************************************************  *;
*       Construct stuff to produce the rug plot.  Need to create an     *;
*       offset position for the pipe marker, which will depend on       *;
*       where the histogram sits on the y-axis. This will requie some   *;
*       trial and error.                                                *;
*     ****************************************************************  *;

gen where=-0.045;

gen pipe = "|";

egen tag_nonslav = tag(congruence_cdf_pop100);

*     ****************************************************************  *;
*       Construct variable to produce y=0 line.                         *;
*     ****************************************************************  *;

gen yline=0;

*     ****************************************************************  *;
*     ****************************************************************  *;
*       Produce marginal effect plot for X.                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;

# delimit ;

graph twoway hist congruence_cdf_pop100  if congruence_cdf_pop100 <=2.5, width(0.1) percent color(gs14) yaxis(2)
		||   scatter where congruence_cdf_pop100  if tag_nonslav & congruence_cdf_pop100 <=2.5, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off)
	    ||   line conbx   MVZ, clpattern(solid) clwidth(medium) clcolor(black) yaxis(1)
        ||   line upperx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line lowerx  MVZ, clpattern(dash) clwidth(thin) clcolor(black)
        ||   line yline  MVZ,  clwidth(thin) clcolor(black) clpattern(solid)
	    ||   ,
			 xlabel(0 (0.5)2, nogrid labsize(3)) 
			 ylabel(-0.05 0 0.1 0.2 0.3 0.4 0.5, axis(1) nogrid labsize(2))
	         yscale(noline alt)
		     yscale(noline alt axis(2))	
             xscale(noline)
             legend(off)
             xtitle("" , size(2.5)  )
             ytitle("" , axis(2) size(2.5))
             xsca(titlegap(2))
             ysca(titlegap(2))
			 scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));


			 
 cd "/Users/sungmhan/Desktop/IPSA_Han_Tang_2019/Empirics"
gr combine  FigureA2a.gph FigureA2b.gph ,  scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white))



*** Figure A5
 meprobit Popvote_update c.import_shock_new##c.congruence_cdf_country1  `control' `ind_con'  i.year   || countrycode:  || countrycode_year: ,
	 
margins, dydx(import_shock_new) at(congruence_cdf_country1 =(0.2(0.2)1.6)) level(90)
	
	marginsplot, ///
             graphregion(color(white))     /// get rid of the gray outerbox
             ci1opts(recast(rline) fintensity(15) lpattern(dash_3dot)) /// add dash
             recast(line)    /// get rid of the big dots
             yline(0, lpattern(solid)           /// add dash horizontal line at 0
             lwidth(vthin) lcolor(black))    /// make line thin, black
             ylabel( , angle(0) nogrid)       /// horiz. y-axis labels & no grid
             xtitle("")         /// x-axis title
             xlabel(0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1" 1.2 "1.2" 1.4 "1.4", labsize(2.5) nogrid) ///
             xtitle("Ideological Incongruence") ///
             ytitle("Marginal Effect of China Import Shock") /// y-axit title
             title("Marginal Effect Based on Coefficient Estimates in Model 8") /// main title
             note("95% confidence intervals")     /// small note of confidence int.
             addplot(hist congruence_cdf_country1, color(gs14%40)      /// add the density
             yaxis(2) yscale(off axis(2)))




  
	
